﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using ilanver.Data.NHibernate;
using ilanver.Data.NHibernate.Abstraction;
using NHibernate;

namespace ilanver.Wcf.CoreLibrary.NHibernate
{
    internal class SessionInstanceExtension : IExtension<InstanceContext>, ISessionStorage
    {
        public SessionInstanceExtension() { }

        public void Attach(InstanceContext owner) { }
        public void Detach(InstanceContext owner) { }

        #region ISessionStorage Members

        public ISession GetSessionForKey(string factoryKey)
        {
            return storage.GetSessionForKey(factoryKey);
        }

        public void SetSessionForKey(string factoryKey, ISession session)
        {
            storage.SetSessionForKey(factoryKey, session);
        }

        public System.Collections.Generic.IEnumerable<ISession> GetAllSessions()
        {
            return storage.GetAllSessions();
        }

        #endregion

        private SimpleSessionStorage storage = new SimpleSessionStorage();
    }
}
